1. Field of the Invention
The present invention relates to a communication apparatus, a method for controlling the communication apparatus, and a storage medium.
2. Description of the Related Art
Among printing apparatuses such as printers or multifunction peripherals, the ones having a wireless local area network (LAN) function have been increasing in number. The printing apparatus having the wireless LAN function connects to an access point as a client, and then performs communication with an apparatus such as a personal computer (PC) or a mobile terminal via the access point. Japanese Patent Application Laid-Open No. 2002-111860 discusses a technique for simply identifying a desired access point from among a plurality of surrounding access points, then attempting to perform the wireless connection.
Further, the standard called Wi-Fi Direct (registered trademark) is established by the Wi-Fi Alliance. In the Wi-Fi Direct, a protocol is defined for determining whether a communication apparatus such as a printing apparatus or a PC operates as an access point or a client. By executing the protocol, a communication apparatus that becomes an access point, and a communication apparatus that becomes a client can be automatically determined. By using the Wi-Fi Direct, the need to separately prepare an access point is eliminated, and communication apparatuses can execute direct wireless communications with each other.
FIG. 1 is a diagram schematically illustrating a processing sequence of the Wi-Fi Direct. Both a printing apparatus and a mobile terminal are assumed to support the Wi-Fi Direct.
First of all, in step S101, the printing apparatus and the mobile terminal mutually search for a communication partner, and then identify the communication partner. When the communication partner is identified, in step S102, it is determined which becomes an access point (group owner), and which becomes a client. The processing in step S102 is called a role determination. In FIG. 1, it is assumed that the printing apparatus has become a group owner, and the mobile terminal has become a client, as a result of the role determination in step S102.
Next, in step S103, by providing parameters for performing connection from the printing apparatus serving as a group owner to the mobile terminal serving as a client, using the Wi-Fi Protected Setup (WPS) defined by the Wi-Fi Alliance, the printing apparatus and the mobile terminal share the parameters therebetween. Then in step S104, the secure connection is performed using the parameters.
When the secure connection is completed, in step S105, addressing is performed for executing an Internet Protocol (IP) communication between the printing apparatus and the mobile terminal. At that time, the printing apparatus which is the group owner operates as a dynamic host configuration protocol (DHCP) server, and assigns an IP address to the mobile terminal which is the client.
A basic processing sequence of the Wi-Fi Direct is described above. By executing the present processing sequence, the printing apparatus and the mobile terminal become able to execute the direct wireless communication, without separately preparing an access point.
By using the above-described Wi-Fi Direct, a plurality of communication apparatuses can perform direct communications easily by identifying their communication partners. However, for example, when the printing apparatus and a first mobile terminal mutually search for a communication partner, if a second mobile terminal different from the first mobile terminal also searches for a communication partner, the printing apparatus may identify the second mobile terminal instead of the first mobile terminal as a communication partner. In this case, for a user of the first mobile terminal, the printing apparatus has come to be connected with the second mobile terminal, which is unintended by the user. While remaining unaware of it, when the user of the first mobile terminal tries to transmit data from the printing apparatus to the mobile terminal, there is an issue that the data is transmitted to the second mobile terminal instead of the first mobile terminal.